package ua.simplecoding.kievhome.controller {

import mx.collections.ArrayCollection;

import ua.simplecoding.kievhome.command.GetAppartmentSummaryListMessage;
import ua.simplecoding.kievhome.domain.AppartmentModel;

public class AppartmentListController {
    private var _appartmentModel:AppartmentModel;

//        [Bindable]
//        [CommandStatus(type="com.adobe.txi.todo.application.GetTodoListMessage")]
//        public var getAllInProgress:Boolean;

//        [Bindable]
//        [PublishSubscribe(objectId="currentAppartmentSummary")]
//        public var currentTodoItem:AppartmentSummaryVO;

    [Bindable]
    [Subscribe(objectId="appartmentSummaryList")]
    public var appartmentSummaryList:ArrayCollection = new ArrayCollection();

    [MessageDispatcher]
    public var dispatcher:Function;

    [Init]
    public function initialize():void {
        getAll();
    }

    [Inject]
    public function set appartmentModel(value:AppartmentModel):void {
        _appartmentModel = value;
    }

    public function getAll():void {
        //reset the current list
        _appartmentModel.appartmentSummaryList = null;

        //call server operation
        dispatcher(new GetAppartmentSummaryListMessage());
    }

//        public function addNewTodoItem():void
//        {
//            var newTodoItem:TodoItem = _appartmentModel.createNewTodoItem();
//
//            currentTodoItem = newTodoItem;
//        }
//
//		public function deleteItem(todoItem:TodoItem):void
//		{
//			//call server operation
//            dispatcher(new RemoveTodoItemMessage(todoItem));
//		}


}
}